package caiziyou.com.juc.cas;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * CAS -> compareAndSet
 * 比较并交换
 * compareAndSwap
 * 
 * Unsafe + CAS(自旋)
 * 
 * ABA问题：狸猫换太子
 * 
 * 
 * @author Administrator
 *
 */
public class CASDemo {

	public static void main(String[] args) {
		AtomicInteger atomicInteger = new AtomicInteger(5);
		System.out.println(atomicInteger.compareAndSet(5, 11) + "\t current data " + atomicInteger.get());
		System.out.println(atomicInteger.compareAndSet(5, 11) + "\t current data " + atomicInteger.get());
	}
}
